package com.woniuxy.controller;

import com.woniuxy.entity.RbacPerm;
import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.service.RbacPermService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("rbacPerm")
public class RbacPermController {
    @Autowired
    RbacPermService rbacPermService;
    @GetMapping("/{currentPage}/{pageSize}")
    public ResponseEntity findAll(@PathVariable("currentPage") int currentPage,@PathVariable("pageSize") int pageSize){
        return rbacPermService.findAll(currentPage,pageSize);
    }
    @PostMapping("/")
    public ResponseEntity addOne(@RequestBody RbacPerm rbacPerm){
        return rbacPermService.addOne(rbacPerm);
    }
    @DeleteMapping("/{id}")
    public ResponseEntity deleteOne(@PathVariable int id){
        return rbacPermService.deleteOne(Integer.parseInt(String.valueOf(id)));
    }
    @PutMapping("/")
    public ResponseEntity updateOne(@RequestBody RbacPerm rbacPerm){
        return rbacPermService.updateOne(rbacPerm);
    }

    @GetMapping("/{id}")
    public ResponseEntity editType(@PathVariable int id){
        return rbacPermService.editType(id);
    }
   @GetMapping("/{currentPage}/{pageSize}/{name}/{code}")
    public ResponseEntity search(@PathVariable int currentPage, @PathVariable int pageSize, @PathVariable String name, @PathVariable String code) {
        return rbacPermService.search(currentPage, pageSize, name, code);
    }
}
